/**
 * @author LKQ
 * @date 2022/1/9 10:01
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] releaseTimes = {12, 23, 36, 46, 62};
        System.out.println(solution.slowestKey(releaseTimes, "spuda"));
    }
    public char slowestKey(int[] releaseTimes, String keysPressed) {
        char ans = keysPressed.charAt(0);
        int longestTime = releaseTimes[0], n = releaseTimes.length;
        for (int i = 1; i < n; i++) {
            char temp = keysPressed.charAt(i);
            int time = releaseTimes[i] - releaseTimes[i-1];
            if ((longestTime < time) ||(longestTime == time && temp > ans))  {
                longestTime = time;
                ans = temp;
            }
        }
        return ans;
    }
}
